import { defineStore } from "pinia";
import { computed } from "vue";
import { useStorage } from "@vueuse/core";
import defaultSettings from "@/setting";

export const useUserStore = defineStore("user", () => {
  const user = useStorage("user", {});
  const token = computed(() => user.value?.token);
  const secret = computed(() => user.value?.secret || defaultSettings.secret);

  const clearUser = () => {
    user.value = {};
  };

  return {
    user,
    token,
    secret,

    clearUser,
  };
});
